﻿using Abp.Domain.Repositories;
using shenghua.Common.WordNodes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace shenghua.Basics.CommoditySpecificationParameters
{
    public class CommoditySpecificationParameterManager : WordNodeManager<CommoditySpecificationParameter>
    {
        public CommoditySpecificationParameterManager(IRepository<CommoditySpecificationParameter> commodityClassRepository)
            : base(commodityClassRepository)
        {
        }

        public override async Task<CommoditySpecificationParameter> Add(CommoditySpecificationParameter word)
        {
            word.Name = word.DisplayName;
            await base.Add(word);
            return word;
        }

        public override async Task<CommoditySpecificationParameter> Update(CommoditySpecificationParameter word)
        {
            word.Name = word.DisplayName;
            await base.Update(word);
            return word;
        }

        public async Task<List<CommoditySpecificationParameter>> GetAll(int commodityWareId)
        {
            return _repository.GetAll().Where(r => r.CommodityWareId == commodityWareId).OrderBy(r => r.Sort).ToList();
        }
    }
}
